<!--批量购买-->
<template>
  
     <input-noborder  :id="id" :dataField="dataField" ref="inputs" :data="data" :exdata="exdata" :extype="extype" :exkey="exkey" @input="tableChangeData"  :isreadonly="isreadonly"  ></input-noborder>
                    
</template>
<script>
export default {
    props:['id','value','styles','disabled','data','isreadonly','exdata','dataField','extype','exkey','isNotSave','exdata'],
    name:"glfBatch",
    components:{
         inputNoborder: function (resolve) {
            //异步组件写法
            require(['../input/input-noborder'], resolve)
        },
    },
    data(){
        return{
            gcpb_ex19:""
        }
    },
    created(){
        console.log("重新加载======================="+this.id+"=="+this.dataField)
        this.loadFy();
    },
    methods:{
        tableChangeData(data){
            this.$emit("tableChangeData",data);
        },
        loadFy(){
            let mxInfo=this.data["mxInfo"];
            console.log(mxInfo,"mxInfo====================================================")
            for(let i=0;i<mxInfo.length;i++){
                let gm_id=mxInfo[i].gm_id;
                let mx_ex7=mxInfo[i].mx_ex7;
                let gm_ex2=mxInfo[i].gm_ex2;
                let gcpbc_ex16=mxInfo[i].gcpbc_ex16;
                if(!mx_ex7){
                    mx_ex7=gcpbc_ex16;
                }
                
                let gcpbc_ex2=Number(mx_ex7)*Number(this.gcpb_ex19);
                console.log("mx_ex7="+mx_ex7+"="+gcpbc_ex2+"="+gcpbc_ex16+"="+gm_ex2)
                let gcpbc_ex4=this.data["mxInfo"][i].gcpbc_ex4;
                gcpbc_ex4=!gcpbc_ex4||gcpbc_ex4=="" ? "0":gcpbc_ex4;
               // alert(mx_ex7)
                this.$set(this.data["mxInfo"][i],"gcpbc_ex16",mx_ex7);
                this.$set(this.data["mxInfo"][i],"gcpbc_ex2",gcpbc_ex2);
                this.$set(this.data["mxInfo"][i],"gcpbc_ex6",gm_ex2);
                this.$set(this.data["mxInfo"][i],"gcpbc_ex1",gm_id);
                this.$set(this.data["mxInfo"][i],"gcpbc_ex3",gcpbc_ex2+Number(gm_ex2));
                if(this.data["info"].gcpb_ex12=="迁坟")
                    this.$set(this.data["mxInfo"][i],"gcpbc_ex4",gcpbc_ex2+Number(gm_ex2));
                if(this.data["info"].gcpb_ex12=="迁坟")
                    this.$set(this.data["mxInfo"][i],"gcpbc_ex5","0");
                else
                    this.$set(this.data["mxInfo"][i],"gcpbc_ex5",gcpbc_ex2+Number(gm_ex2)-Number(gcpbc_ex4));
            }
        },
        changeAmt(){
            let mxInfo=this.data["mxInfo"];
            let gcpbc_ex3_=0;
            let gcpbc_ex4_=0;
            let gcpbc_ex5_=0;
            for(let i=0;i<mxInfo.length;i++){

                let gcpbc_ex3=mxInfo[i].gcpbc_ex3;
                let gcpbc_ex4=mxInfo[i].gcpbc_ex4;
                let gcpbc_ex5=mxInfo[i].gcpbc_ex5;
                gcpbc_ex3=!gcpbc_ex3||gcpbc_ex3=="" ? "0":gcpbc_ex3;
                gcpbc_ex4=!gcpbc_ex4||gcpbc_ex4=="" ? "0":gcpbc_ex4;
                gcpbc_ex5=!gcpbc_ex5||gcpbc_ex5=="" ? "0":gcpbc_ex5;
                gcpbc_ex3=Number(gcpbc_ex3);
                gcpbc_ex4=Number(gcpbc_ex4);
                gcpbc_ex5=Number(gcpbc_ex5);
                gcpbc_ex3_=gcpbc_ex3_+gcpbc_ex3;
                gcpbc_ex4_=gcpbc_ex4_+gcpbc_ex4;
                gcpbc_ex5_=gcpbc_ex5_+gcpbc_ex5;

            }
            this.$set(this.data["info"],"gcpb_ex20",gcpbc_ex3_);
            this.$set(this.data["info"],"gcpb_ex21",gcpbc_ex4_);
            this.$set(this.data["info"],"gcpb_ex22",gcpbc_ex5_);
        }
    },
    watch:{
        data:{
            handler: function (newVal) {
                console.log("变更管理费-------------------------")
                let gcpb_ex19=this.data["info"].gcpb_ex19;
              //  if(this.gcpb_ex19!=gcpb_ex19){
                    this.gcpb_ex19=gcpb_ex19;
                    
                    this.loadFy();
                    this.changeAmt();
            //    }
                let az=this.data["gInfo"];
                let mxInfo=this.data["mxInfo"];
                console.log(az);
                console.log(mxInfo)
                try{
                    for(let i=0;i<az.length;i++){
                        let gcpbc_ex1=az[i].gcpbc_ex1;
                        for(let j=0;j<mxInfo.length;j++){
                            let gm_id=mxInfo[j].gm_id;
                            if(gcpbc_ex1==gm_id){
                                this.$set(this.data["mxInfo"][j],"gcpbc_ex7",az[i]["gcpbc_ex7"])
                                this.$set(this.data["mxInfo"][j],"gcpbc_ex8",az[i]["gcpbc_ex8"])
                                this.$set(this.data["mxInfo"][j],"gcpbc_ex9",az[i]["gcpbc_ex9"])
                                this.$set(this.data["mxInfo"][j],"gcpbc_ex10",az[i]["gcpbc_ex10"])
                                this.$set(this.data["mxInfo"][j],"gcpbc_ex11",az[i]["gcpbc_ex11"])
                                this.$set(this.data["mxInfo"][j],"gcpbc_ex12",az[i]["gcpbc_ex12"])
                                this.$set(this.data["mxInfo"][j],"gcpbc_ex13",az[i]["gcpbc_ex13"])
                                this.$set(this.data["mxInfo"][j],"gcpbc_ex14",az[i]["gcpbc_ex14"])
                                this.$set(this.data["mxInfo"][j],"gcpbc_ex15",az[i]["gcpbc_ex15"])
                                this.$set(this.data["mxInfo"][j],"c_nam",az[i]["gcpbc_ex7"])
                            }
                        }
                    }
                }catch(e){}
                
                for(let i=0;i<mxInfo.length;i++){
                    let gcpbc_ex7=mxInfo[i].gcpbc_ex7;
                    let c_nam=mxInfo[i].c_nam;
                    if(gcpbc_ex7&&c_nam!=gcpbc_ex7){
                        this.$set(this.data["mxInfo"][i],"c_nam",gcpbc_ex7)
                    }
                }
            },      
            deep: true    //深度监听
        }
    }
}
</script>